import 'dart:io';

import 'package:filelinker/mdsn.dart';
import 'package:filelinker/netsev.dart';
import 'package:filelinker/portal.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  if (!Platform.isAndroid) {
    await NetService.shared.preload();
  } else {
    await NetService.shared.preloadPermission();
  }
  runApp(const MyApp());
  preload();
}

void preload() {
  MDNS.shared.start();
}

void configLoading() {
  EasyLoading.instance
    ..displayDuration = const Duration(milliseconds: 2000)
    ..indicatorType = EasyLoadingIndicatorType.doubleBounce
    ..loadingStyle = EasyLoadingStyle.light
    ..radius = 10.0
    ..userInteractions = true
    ..dismissOnTap = false;
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FileLinker',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: const Color(0xFF758694),
          brightness: Brightness.light,
        ),
        useMaterial3: true,
      ),
      home: const PortalPage(),
      builder: EasyLoading.init(),
    );
  }
}
